/* 
 * Copyright [2018] [Alex/libo(liboms@hotmail.com)]
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.hyts.guava.imcollection;

import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.google.common.collect.ImmutableList;

/** 
 * @title ImmutableLists.java  
 * @package com.hyts.guava.collection  
 * @description 不可变的List集合服务操作；
 * 				代替Java api原生的 Collections.unmodifiableList
 * 				不可变的操作，原生的效率一般而且不是真正的不变的操作
 * @see Collections.unmodifiableList
 * @author libo/Alex
 * @email liboms@hotmail.com/liboware@163.com  
 * @date 2018年5月5日 
 * @version V1.0 
 */
public final class ImmutableLists {

	/**  
	 * <b>create:创建ImmutableList不可变集合</b>
	 * <p>创建ImmutableList不可变集合->使用Guava的copyOf方法</p>
	 * @param elements
	 * @return
	 * @exception
	 */ 
	public static <T> ImmutableList<T> create(Collection<T> elements){
		return ImmutableList.copyOf(elements);
	}
	
	/**  
	 * <b>create:创建ImmutableList不可变集合</b>
	 * <p>创建ImmutableList不可变集合->使用Guava的copyOf方法</p>
	 * @param elements
	 * @return
	 * @exception
	 */ 
	public static <T> ImmutableList<T> create(List<T> elements){
		return ImmutableList.copyOf(elements);
	}
	
	/**  
	 * <b>create:创建ImmutableList不可变集合</b>
	 * <p>创建ImmutableList不可变集合->使用Guava的copyOf方法</p>
	 * @param elements
	 * @return
	 * @exception
	 */ 
	public static <T> ImmutableList<T> create(T[] elements){
		return ImmutableList.copyOf(elements);
	}
	
	/**  
	 * <b>create:创建ImmutableList不可变集合</b>
	 * <p>创建ImmutableList不可变集合->使用Guava的copyOf方法</p>
	 * @param elements
	 * @return
	 * @exception
	 */ 
	public static <T> ImmutableList<T> create(Set<T> elements){
		return ImmutableList.copyOf(elements);
	}
	
	/**  
	 * <b>create:创建ImmutableList不可变集合</b>
	 * <p>创建ImmutableList不可变集合->使用Guava的copyOf方法</p>
	 * @param elements
	 * @return
	 * @exception
	 */ 
	public static <T> ImmutableList<T> create(Iterator<T> elements){
		return ImmutableList.copyOf(elements);
	}
	
}
